<template>
<view class="container padding sec-top">
	<view class="flex-center">
		<image class="profile-banner-cover"
			src="/static/base_ac.png"
			mode="aspectFill" />
	</view>
	<view class="profile-banner detail-white sec-top">
		<view class="task-list">
			<view class="task-item border"
				@click="onTaskItem('update')">
				<view class="task-item-content">
					<text>检查更新</text>
				</view>
			</view>
			<view class="task-item border"
				@click="onTaskItem('cooperate')">
				<view class="task-item-content">
					<text>合作洽谈</text>
				</view>
			</view>
			<view class="task-item border"
				@click="onTaskItem('report')">
				<view class="task-item-content">
					<text>申诉举报</text>
				</view>
			</view>
			<view class="task-item"
				@click="onTaskItem('hotline')">
				<view class="task-item-content">
					<text>客服热线</text>
				</view>
			</view>
		</view>
	</view>
	<!-- 合作洽谈/申诉举报 -->
	<uni-popup id="dialog"
		ref="dialog"
		type="center"
		:animation="true">
		<view class="popup text-custom">
			<view class="section-header" style="padding: 0;">
				<view class="section-title">
					<text class="sec-left text-primary">{{ content.title }}</text>
				</view>
				<view class="section-suffix">
					<text class="iconfont icon-close"
						@click="onClose"></text>
				</view>
			</view>
			<view class="popup-input sec-top">
				<rich-text :nodes="content.body"></rich-text>
			</view>
			<view class="shim-small"></view>
		</view>
	</uni-popup>
	<!-- 弹窗 -->
	<uni-popup id="popup"
		ref="popup"
		type="center"
		:animation="true">
		<view class="popup text-custom">
			<view class="popup-input">
				<text class="iconfont icon-close"
					@click="onClose"></text>
			</view>
			<view class="popup-input">
				合作请使用以下邮箱。如需反馈建筑考研汪使用问题或建议，请返回进入 [帮助中心] 提交反馈。
			</view>
			<view class="popup-input sec-top">
				<view>商务合作：business@*****.com</view>
				<view>文章投稿：contributes@*****.com</view>
				<view>广告合作：advertisement@*****.com</view>
			</view>
			<view class="shim-small"></view>
		</view>
	</uni-popup>
</view>
</template>

<script>
import { getAboutme } from '@/api/index.js'
export default {
	data() {
		return {
			app101: {},
			app103: {},
			content: {}
		}
	},
	onShow() {
		const token = uni.getStorageSync('X-Auth-Token');
		if (!token) {
			uni.navigateTo({
				url: '/pages/login/login'
			});
		}
		getAboutme('app101').then(res => {
			this.app101 = res.data;
		});
		getAboutme('app103').then(res => {
			this.app103 = res.data;
		});
	},
	methods: {
		onClose() {
			this.$refs.popup.close();
			this.$refs.dialog.close();
		},
		onTaskItem(type) {
			switch(type) {
				case 'update':
					break;
				case 'cooperate':
					this.content = this.app101;
					this.$refs.dialog.open();
					break;
				case 'report':
					this.content = this.app103;
					this.$refs.dialog.open();
					break;
				case 'hotline':
					this.$refs.popup.open();
					break;
				default:
					break;
			}
		}
	}
}
</script>
